dialog [nfc]: Wrap showErrorDialog's return value#970
Merged
gnprice merged 2 commits intozulip:mainfrom Oct 7, 2024
Merged
Conversation
c74d3cc to
5c9b550
Compare
chrisbobbe
reviewed
Oct 5, 2024
Collaborator
chrisbobbe
left a comment
There was a problem hiding this comment.
Small comments below, otherwise LGTM. Thanks!
lib/widgets/dialog.dart
Outdated
Comment on lines
25
to
26
| final Future<void> _closed; | ||
| /// Resolves when the dialog is closed. | ||
| Future<void> get closed => _closed; |
Collaborator
There was a problem hiding this comment.
lib/widgets/lightbox.dart
Outdated
| // Wait until the dialog is closed | ||
| await dialog.closed; |
Collaborator
There was a problem hiding this comment.
Happily, I think the comment is now redundant and can be swept away :)
1e20eba to
59fd8ae
Compare
Member
Author
|
Thanks for the review! Updated the PR. |
de48f34 to
59fd8ae
Compare
Collaborator
|
LGTM, thanks! Over to Greg. |
As a result, showErrorDialog no longer returns a Future that can be mistakenly awaited. The wrapped return value offers clarity on how the Future is supposed to be used. There is no user visible change because existing callers (other than lightbox's) that wait for its return value are all asynchronous handlers for UI elements like buttons, and waits unnecessarily. See also discussion zulip#937 (comment). Signed-off-by: Zixuan James Li <zixuan@zulip.com>
Unlike ScaffoldFeatureController which inspired it, this class doesn't offer a way to control the dialog, so it's not really a "controller"; just call it DialogStatus. A private final field with a public getter (of the same type) is equivalent to just a public final field: nothing can set it, and any library can get it. Also generalize the description a bit: we currently use this only for AlertDialog, but it'd apply equally well for any dialog box.
59fd8ae to
c5f4e93
Compare
Member
|
Thanks to you both! Looks good; merging, with some tweaks to the interface on top: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As a result, showErrorDialog no longer returns a Future that can be mistakenly awaited. The wrapped return value offers clarity on how the Future is supposed to be used.
There is no user visible change because existing callers (other than lightbox's) that wait for its return value are all asynchronous handlers for UI elements like buttons, and waits unnecessarily.
See also discussion
#937 (comment).